﻿<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="Bookmark" href="favicon.ico" >
	<link rel="Shortcut Icon" href="favicon.ico" />
	<!--[if lt IE 9]>
	<script type="text/javascript" src="/lib/html5.js"></script>
	<script type="text/javascript" src="/lib/respond.min.js"></script>
	<![endif]-->
	<link rel="stylesheet" type="text/css" href="/static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="/lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/css/style.css" />
	<!--[if IE 6]>
	<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
	<script>DD_belatedPNG.fix('*');</script>
	<![endif]-->
	<title>新建网站角色 - 管理员管理</title>
	<meta name="keywords" content="洛阳易购商城">
	<meta name="description" content="洛阳易购商城">
</head>
<body>
<article class="cl pd-20">
<input type="hidden" id="module_id"value="{$module_info['module_id']}"/>
	<form action="" method="post" class="form form-horizontal" id="form-admin-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>模块名：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" placeholder="请输入模块名称" value="{$module_info['module_name']}" id="module_name">
				<p class="error">请输入控制器名</p>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>上级菜单：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<span class="select-box">
					<select class="select" size="1" id="pid">
						<option value="0">顶级菜单</option>
					{foreach name="list" item="v1"}
					<option {if condition="$v1['data']['module_id']==$module_info['pid']"}selected{/if} value="{$v1['data']['module_id']}">&nbsp;&nbsp;&nbsp;{$v1['data']['module_name']}</option>
					{foreach name="v1['sub_menu']" item="v2"}
					<option {if condition="$v2['module_id']==$module_info['pid']"}selected{/if} value="{$v2['module_id']}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$v2['module_name']}</option>
					{/foreach}
					{/foreach}
					</select>
				</span>
				<p class="error">请输入控制器名</p>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>控制器名：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text"  value="{$module_info['controller']}" class="input-text" id="controller">
				<p class="error">请输入控制器名</p>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>方法名：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" value="{$module_info['method']}" class="input-text" id="method">
				<p class="error">请输入方法名</p>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>URL：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$module_info['url']}" id="url">
				<p class="error">请输入URL</p>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>排序：</label>
			<div class="formControls col-xs-8 col-sm-3">
				<input type="text" value="{$module_info['sort']}" class="input-text" id="sort" value="0">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">是否是菜单：</label>
			<div class="formControls col-xs-8 col-sm-3 skin-minimal">
				<div class="check-box">
					<input type="checkbox" id="is_menu" {if condition="$module_info.is_menu eq 1"}checked="checked"{/if}>
					<label for="is_menu">&nbsp;</label>
				</div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">是否控制权限：</label>
			<div class="formControls col-xs-8 col-sm-3 skin-minimal">
				<div class="check-box">
					<input type="checkbox" id="is_control_auth" {if condition="$module_info.is_control_auth eq 1"}checked="checked"{/if}>
					<label for="is_control_auth">&nbsp;</label>
				</div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">图标：</label>
			<div class="formControls col-xs-8 col-sm-3">
				<input type="text" value="{$module_info['logo']}" class="input-text Hui-iconfont" id="logo">
				<span>图标地址：
					<a target="_blank" href="http://h-ui.net/Hui-3.7-Hui-iconfont.shtml">图标库</a>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">备注：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<textarea class="textarea" id="desc" placeholder="说点什么...100个字符以内" >{$module_info['info']}</textarea>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="button" onclick="addModuleAjax()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>
<script type="text/javascript" src="/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="/static/h-ui.admin/js/H-ui.admin.page.js"></script>
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
    $(function() {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
    })
    var flag = false;//防止重复提交
    function addModuleAjax() {
        var module_id = $("#module_id").val();
        var pid = $("#pid").val();
        var module_name = $("#module_name").val();
        var controller = $("#controller").val();
        var method = $("#method").val();
        var url = $("#url").val();
        var is_menu = $("#is_menu").val();//是否是菜单
        var is_control_auth = 1;//是否控制权限，默认控制
        var is_dev = $("#is_dev").val();//是否仅开发者模式可见
        var sort = $("#sort").val();
        var desc = $("#desc").val();
        if($("#is_menu").prop("checked")){
            var is_menu = 1;
        }else{
            var is_menu = 0;
        }
        if(!$("#is_control_auth").prop("checked")){
            is_control_auth = 0;
        }
        var module_picture = $("#logo").val();
        if(verify(module_name, controller, method, url, sort, desc)){
            if(flag){
                return;
            }
            flag = true;
            $.ajax({
                type : "post",
                url : "{:url('admin/admin_permission_edit')}",
                data : {
                    'module_id' : module_id,
                    'pid' : pid,
                    'module_name' : module_name,
                    'controller' : controller,
                    'method' : method,
                    'url' : url,
                    'is_menu' : is_menu,
                    'is_control_auth' : is_control_auth,
                    'sort' : sort,
                    'module_picture' : module_picture,
                    'desc' : desc
                },
                success : function(data) {
                    if (data > 0) {
                        layer.msg('修改成功!', {icon: 1, time: 1000},function () {
                            window.parent.location.reload();
                            var index=parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }else{
                        layer.msg('修改失败!', {icon: 2, time: 1000});
                        flag = false;
                    }
                }
            });
        }
    }
    //模块输入信息验证
    function verify(module_name, controller, method, url,  sort, desc){
        if(module_name == ''){
            $("#module_name").next().show();
            return false;
        }else{
            $(".error").hide();
        }
        if(controller == ''){
            $("#controller").next().show();
            return false;
        }else{
            $(".error").hide();
        }
        if(method == ''){
            $("#method").next().show();
            return false;
        }else{
            $(".error").hide();
        }
        if(url == ''){
            $("#url").next().show();
            return false;
        }else{
            $(".error").hide();
        }
        return true;
    }
</script>
</body>
</html>